package com.david.zhufengfm.tasks;

import com.david.zhufengfm.Constants;
import com.david.zhufengfm.client.ClientAPI;
import com.david.zhufengfm.utils.EntityParseUtil;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by David on 2015/10/24.
 * qq:978944820
 */
public class PlayTracksTask extends BaseTask{


    public PlayTracksTask(TaskCallback callback) {
        super(callback);
    }

    @Override
    protected TaskResult doInBackground(String... params) {
        TaskResult result=new TaskResult();
        String albumId=params[0];
        String trackId=params[1];
        if (albumId != null) {

            result.action= Constants.TAST_PLAY_TRACKS;
            JSONObject jsonObject= ClientAPI.getPlayList(Long.parseLong(albumId),Long.parseLong(trackId));
            if (jsonObject != null) {
                try {
                    result.resultCode=jsonObject.getInt("ret");
                    result.data= EntityParseUtil.getPlayTracks(jsonObject);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
        return result;
    }
}
